package org.dimock.proxy;

import java.util.Map;

import java.util.concurrent.ConcurrentHashMap;
/**
 * Class needs to be updated to be thread safe
 *
 */
public class ProxyContext {
	private Object redirect;
	private boolean strict;
	private boolean recursive;
	private DependencyResolver dependencyResolver;
	private MethodResolver methodResolver;
	
	private Map<String, Integer> invocationCountMap = new ConcurrentHashMap<String, Integer>();

	public void recordInvocation(String methodName){
		if (!invocationCountMap.containsKey(methodName))
			invocationCountMap.put(methodName, 1);
		else
			invocationCountMap.put(methodName, invocationCountMap.get(methodName) +1 );
	}
	
	public int getInvocationCount(String methodName){
		if (!invocationCountMap.containsKey(methodName))
			return 0;
		return invocationCountMap.get(methodName);
	}

	public Object getRedirect() {
		return redirect;
	}

	public void setRedirect(Object redirect) {
		this.redirect = redirect;
	}

	public boolean isStrict() {
		return strict;
	}

	public void setStrict(boolean strict) {
		this.strict = strict;
	}

	public boolean isRecursive() {
		return recursive;
	}

	public void setRecursive(boolean recursive) {
		this.recursive = recursive;
	}

	public void rest(){
		invocationCountMap.clear();
	}

	public DependencyResolver getDependencyResolver() {
		return dependencyResolver;
	}

	public void setDependencyResolver(DependencyResolver dependencyResolver) {
		this.dependencyResolver = dependencyResolver;
	}

	public MethodResolver getMethodResolver() {
		return methodResolver;
	}

	public void setMethodResolver(MethodResolver methodResolver) {
		this.methodResolver = methodResolver;
	}
	
	
}
